#ifndef FOODSQL_H
#define FOODSQL_H

#include <QObject>
#include <QSqlDatabase>
struct FoodInfo
{
    int id;
    QString name;
    quint8 num;
    quint32 foodid;
    QString foodunit;
    QString date;
};

class foodSql : public QObject
{
    Q_OBJECT
public:
    static foodSql *ptrfoodSql;
    static foodSql *getinstance()
    {
        if(nullptr == ptrfoodSql)
        {
            ptrfoodSql = new foodSql;
        }
        return ptrfoodSql;
    }

    explicit foodSql(QObject *parent = nullptr);

    void init();

    //查询所有食物数量
    quint32 getFoodCut();
    //查询第几页食物数据(从第0页开始)
    QList<FoodInfo> getPageFood(quint32 page,quint32 uiCnt);
    //增加食物
    bool addFood(FoodInfo foodInfo);
    //删除食物
    bool delFood(int id);
    //清空食物表
    void clearFoodTable();
    //修改食物信息
    void updateFoodInfo(FoodInfo foodInfo);
    //查询所有用户

    //查询用户名是否存在

    //修改用户权限

    //添加单个用户

    //删除单个用户
signals:
private:
    QSqlDatabase m_db;
};

#endif // FOODSQL_H
